﻿using Microsoft.Extensions.Configuration;
using SqlSugar.IOC;
using System;
using System.Collections.Generic;

namespace Qy.Scenario;

public static class SqlSugarExtension
{
    public static void AddDataBase(IConfiguration Configuration)
    {
        string connStr = Configuration.GetConnectionString("conn_db");
        int dbType = Convert.ToInt32(Configuration.GetConnectionString("conn_db_type"));

        var iocList = new List<IocConfig>() {
                   new IocConfig() {
                    ConfigId = "0",//默认MySql
                    ConnectionString = connStr,
                    DbType = (IocDbType)dbType,
                    IsAutoCloseConnection = true
                },
                   new IocConfig() {
                    ConfigId = "4",
                    ConnectionString = connStr,
                    DbType = (IocDbType)dbType,
                    IsAutoCloseConnection = true
                }
               //...增加其他数据库
            };
        SugarIocServices.AddSqlSugar(iocList);
    }
}
